import { reqGetSearchInfo } from "@/api"
export default {
	namespaced:true,
	actions:{
	    //获取Search模块数据 
		async getSearchInfo(context,params={}){
		   let result = await reqGetSearchInfo(params)
		   if(result.code == 200){
			   context.commit('GETSEARCHINFO',result.data);
		   }
		}
	},

	mutations:{
	    GETSEARCHINFO(state,searchList){ 
            state.searchList = searchList;
		}  
	},

	state:{
		searchList:{}
	},

	getters:{
		  goodsList(state){
			//state.searchList.goodsList如果服务器数据回来了，没问题是一个数组
			//假如网络不给力|没有网state.searchList.goodsList应该返回的是undefined
			//计算新的属性的属性值至少给人家来一个数组
			return state.searchList.goodsList||[];
		  }
		  ,
		  trademarkList(state){
			return state.searchList.trademarkList||[];
		  },
		  attrsList(state){
			return state.searchList.attrsList||[];
		  },
		  total(state){
            return state.searchList.total;
		  }
	},

}